<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Creates a PHP value from a stored representation from igbinary_serialize</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.igbinary-serialize.html">« igbinary_serialize</a></li>
      <li style="float: right;"><a href="book.json.html">JSON »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.igbinary.html">Igbinary 函数</a></li>
    <li>Creates a PHP value from a stored representation from igbinary_serialize</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.igbinary-unserialize" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">igbinary_unserialize</h1>
  <p class="verinfo">(PECL igbinary &gt;= 1.1.1)</p><p class="refpurpose"><span class="refname">igbinary_unserialize</span> &mdash; <span class="dc-title">
   Creates a PHP value from a stored representation from <span class="function"><a href="function.igbinary-serialize.html" class="function">igbinary_serialize()</a></span>
  </span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.igbinary-unserialize-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>igbinary_unserialize</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$str</code></span>): <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span></div>

  <p class="simpara">
   <span class="function"><strong>igbinary_unserialize()</strong></span> takes a single serialized variable from
   <span class="function"><a href="function.igbinary-serialize.html" class="function">igbinary_serialize()</a></span> and converts it back into a PHP value.
  </p>
  <div class="warning"><strong class="warning">警告</strong>
   <p class="para">
    Untrusted user input must not be passed to <span class="function"><strong>igbinary_unserialize()</strong></span>.
    Unserialization can result in code being loaded and executed due to object
    instantiation and autoloading, and a malicious user may be able to exploit
    this. Instead a safe, standard data interchange format such as JSON (via
    <span class="function"><a href="function.json-decode.html" class="function">json_decode()</a></span> and <span class="function"><a href="function.json-encode.html" class="function">json_encode()</a></span>) should be used,
    if serialized data needs to be passed to a client.
   </p>
   <p class="para">
    If there is the need to unserialize externally-stored serialized data,
    <span class="function"><a href="function.hash-hmac.html" class="function">hash_hmac()</a></span> can be used for data validation.
    It is important to ensure that nobody has tampered with the data.
   </p>
  </div>
  <div class="warning"><strong class="warning">警告</strong>
   <p class="para">
    The igbinary serialization format does not provide a way to distinguish between different reference
    groups for the same value. All PHP references to a given value as treated as part
    of the same reference group when unserialized,
    even if they were parts of difference reference groups when serialized.
   </p>
  </div>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.igbinary-unserialize-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">str</code></dt>

    <dd>

     <p class="para">
      The serialized string generated by <span class="function"><a href="function.igbinary-serialize.html" class="function">igbinary_serialize()</a></span>.
     </p>
     <p class="para">
      If the value being unserialized is an <span class="type">object</span>, after successfully
      reconstructing the object igbinary will automatically attempt to call the
      <a href="language.oop5.magic.html#object.unserialize" class="link">__unserialize()</a> or
      <a href="language.oop5.magic.html#object.wakeup" class="link">__wakeup()</a> methods (if one exists).
     </p>
     <p class="para">
      <blockquote class="note"><p><strong class="note">注意</strong>: 
       <strong>unserialize_callback_func directive</strong><br />
       <p class="para">
        It is possible to set a callback function which will be called,
        if an undefined class should be instantiated during unserializing.
        (to prevent getting an incomplete <span class="type">object</span> <code class="literal">__PHP_Incomplete_Class</code>.)
        The <var class="filename">php.ini</var>, <span class="function"><a href="function.ini-set.html" class="function">ini_set()</a></span> or <var class="filename">.htaccess</var> can be used
        to define <a href="var.configuration.html#ini.unserialize-callback-func" class="link">unserialize_callback_func</a>.
        Everytime an undefined class should be instantiated, it will be called.
        To disable this feature this setting should be emptied.
       </p>
      </p></blockquote>
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.igbinary-unserialize-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   The converted value is returned, and can be a <span class="type">bool</span>,
   <span class="type">int</span>, <span class="type">float</span>, <span class="type">string</span>,
   <span class="type">array</span>, <span class="type">object</span>, or <span class="type">null</span>.
  </p>
  <p class="para">
   In case the passed string is not unserializeable, <strong><code>false</code></strong> is returned and
   <strong><code>E_NOTICE</code></strong> or <strong><code>E_WARNING</code></strong> is issued.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.igbinary-unserialize-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   Objects may throw <span class="classname"><a href="class.throwable.html" class="classname">Throwable</a></span>s in their unserialization handlers.
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.igbinary-unserialize-notes">
  <h3 class="title">注释</h3>
  <div class="warning"><strong class="warning">警告</strong>
   <p class="para">
    <strong><code>null</code></strong> or <strong><code>false</code></strong> is returned both in the case of an error and if unserializing
    the serialized <strong><code>null</code></strong> or <strong><code>false</code></strong> value. It is possible to catch this special case by
    comparing <code class="parameter">str</code> with
    <code class="code">igbinary_serialize(null)</code> or <code class="code">igbinary_serialize(false)</code>
    or by catching the issued <strong><code>E_NOTICE</code></strong>.
   </p>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.igbinary-unserialize-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.unserialize.html" class="function" rel="rdfs-seeAlso">unserialize()</a> - 从已存储的表示中创建 PHP 的值</span></li>
    <li class="member"><span class="function"><a href="function.json-encode.html" class="function" rel="rdfs-seeAlso">json_encode()</a> - 对变量进行 JSON 编码</span></li>
    <li class="member"><span class="function"><a href="function.json-decode.html" class="function" rel="rdfs-seeAlso">json_decode()</a> - 对 JSON 格式的字符串进行解码</span></li>
    <li class="member"><span class="function"><a href="function.hash-hmac.html" class="function" rel="rdfs-seeAlso">hash_hmac()</a> - 使用 HMAC 方法生成带有密钥的散列值</span></li>
    <li class="member"><span class="function"><a href="function.igbinary-serialize.html" class="function" rel="rdfs-seeAlso">igbinary_serialize()</a> - Generates a compact, storable binary representation of a value</span></li>
    <li class="member"><a href="language.oop5.autoload.html" class="link">Autoloading Classes</a></li>
    <li class="member"><a href="var.configuration.html#ini.unserialize-callback-func" class="link">unserialize_callback_func</a></li>
    <li class="member"><a href="language.oop5.magic.html#object.wakeup" class="link">__wakeup()</a></li>
    <li class="member"><a href="language.oop5.magic.html#object.serialize" class="link">__serialize()</a></li>
    <li class="member"><a href="language.oop5.magic.html#object.unserialize" class="link">__unserialize()</a></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>